package com.mtbu.bean.base;
import java.util.*;
import java.text.SimpleDateFormat;
import org.json.JSONObject;
import my.json.core.JsonAble;
public abstract class SysModuleBase implements JsonAble {
    private Map<String, Object> dirtyProperties = new HashMap<String, Object>();
    //
    private int id = 0;
    //
    private String moduleID = "";
    //
    private String moduleName = "";
    //
    private String parentID = "";
    //
    private String link = "";
    //
    private String linkClass = "";
    //
    private int status = 0;
    //
    private String memo = "";
    //
    private Date createTime = null;
    public int getId(){
        return this.id;
    }
    public void setId(int id){
        this.id = id;
    }
    public String getModuleID(){
        return this.moduleID;
    }
    public void setModuleID(String moduleID){
        this.moduleID = moduleID;
        dirtyProperties.put("moduleID", moduleID);
    }
    public String getModuleName(){
        return this.moduleName;
    }
    public void setModuleName(String moduleName){
        this.moduleName = moduleName;
        dirtyProperties.put("moduleName", moduleName);
    }
    public String getParentID(){
        return this.parentID;
    }
    public void setParentID(String parentID){
        this.parentID = parentID;
        dirtyProperties.put("parentID", parentID);
    }
    public String getLink(){
        return this.link;
    }
    public void setLink(String link){
        this.link = link;
        dirtyProperties.put("link", link);
    }
    public String getLinkClass(){
        return this.linkClass;
    }
    public void setLinkClass(String linkClass){
        this.linkClass = linkClass;
        dirtyProperties.put("linkClass", linkClass);
    }
    public int getStatus(){
        return this.status;
    }
    public void setStatus(int status){
        this.status = status;
        dirtyProperties.put("status", status);
    }
    public String getMemo(){
        return this.memo;
    }
    public void setMemo(String memo){
        this.memo = memo;
        dirtyProperties.put("memo", memo);
    }
    public Date getCreateTime(){
        return this.createTime;
    }
    public String getCreateTime_ToDateString(){
        if(createTime==null) return "";
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        return formatter.format(this.createTime);
    }
    public String getCreateTime_ToTimeString(){
        if(createTime==null) return "";
        SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss");
        return formatter.format(this.createTime);
    }
    public String getCreateTime_ToDateTimeString(){
        if(createTime==null)   return "";
        SimpleDateFormat   formatter   =   new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return formatter.format(this.createTime);
    }
    public void setCreateTime(Date createTime){
        this.createTime = createTime;
        dirtyProperties.put("createTime", createTime);
    }
    public Map<String, Object> getDirtyProperties() {
        return this.dirtyProperties;
    }
    public JSONObject toJSON() throws Exception {
        JSONObject json = new JSONObject();
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        json.put("id", this.getId());
        if(moduleID!=null){
           json.put("moduleID",this.getModuleID());
        }
        if(moduleName!=null){
           json.put("moduleName",this.getModuleName());
        }
        if(parentID!=null){
           json.put("parentID",this.getParentID());
        }
        if(link!=null){
           json.put("link",this.getLink());
        }
        if(linkClass!=null){
           json.put("linkClass",this.getLinkClass());
        }
        json.put("status", this.getStatus());
        if(memo!=null){
           json.put("memo",this.getMemo());
        }
        if(createTime!=null){
            json.put("createTime",formatter.format(this.getCreateTime()));
        }
        return json;
    }
    public void fromJSON(JSONObject json) throws Exception {
        if(json==null) return;
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        try{
            if(json.get("id") != null){
                this.setId(Integer.parseInt(json.get("id")+""));
            }
        }catch(Exception ex){
        }
        try{
            if(json.get("moduleID") != null){
                this.setModuleID(json.get("moduleID")+"");
            }
        }catch(Exception ex){
        }
        try{
            if(json.get("moduleName") != null){
                this.setModuleName(json.get("moduleName")+"");
            }
        }catch(Exception ex){
        }
        try{
            if(json.get("parentID") != null){
                this.setParentID(json.get("parentID")+"");
            }
        }catch(Exception ex){
        }
        try{
            if(json.get("link") != null){
                this.setLink(json.get("link")+"");
            }
        }catch(Exception ex){
        }
        try{
            if(json.get("linkClass") != null){
                this.setLinkClass(json.get("linkClass")+"");
            }
        }catch(Exception ex){
        }
        try{
            if(json.get("status") != null){
                this.setStatus(Integer.parseInt(json.get("status")+""));
            }
        }catch(Exception ex){
        }
        try{
            if(json.get("memo") != null){
                this.setMemo(json.get("memo")+"");
            }
        }catch(Exception ex){
        }
        try{
            if(json.get("createTime") != null){
                this.setCreateTime(formatter.parse(json.get("createTime")+""));
            }
        }catch(Exception ex){
        }
    }
    public void fromMap(Map<String, String> json) throws Exception {
        if(json==null) return;
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        try {
            if(json.containsKey("id".toLowerCase())){
                this.setId(Integer.parseInt(json.get("id".toLowerCase())+""));
            }
        }catch(Exception ex){
        }
        try {
            if(json.containsKey("moduleID".toLowerCase())){
                this.setModuleID(json.get("moduleID".toLowerCase())+"");
            }
        }catch(Exception ex){
        }
        try {
            if(json.containsKey("moduleName".toLowerCase())){
                this.setModuleName(json.get("moduleName".toLowerCase())+"");
            }
        }catch(Exception ex){
        }
        try {
            if(json.containsKey("parentID".toLowerCase())){
                this.setParentID(json.get("parentID".toLowerCase())+"");
            }
        }catch(Exception ex){
        }
        try {
            if(json.containsKey("link".toLowerCase())){
                this.setLink(json.get("link".toLowerCase())+"");
            }
        }catch(Exception ex){
        }
        try {
            if(json.containsKey("linkClass".toLowerCase())){
                this.setLinkClass(json.get("linkClass".toLowerCase())+"");
            }
        }catch(Exception ex){
        }
        try {
            if(json.containsKey("status".toLowerCase())){
                this.setStatus(Integer.parseInt(json.get("status".toLowerCase())+""));
            }
        }catch(Exception ex){
        }
        try {
            if(json.containsKey("memo".toLowerCase())){
                this.setMemo(json.get("memo".toLowerCase())+"");
            }
        }catch(Exception ex){
        }
        try {
            if(json.containsKey("createTime".toLowerCase())){
                this.setCreateTime(formatter.parse(json.get("createTime".toLowerCase())+""));
            }
        }catch(Exception ex){
        }
    }
}
